//
//  MainViewController.swift
//  SinaWeibo
//
//  Created by 臧英振 on 16/1/30.
//  Copyright © 2016年 zyz. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    @objc private func plusBtnDidClick() {
        print(__FUNCTION__)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        
        let mainTabbar = MainTabbar()
        
        setValue(mainTabbar, forKey: "tabBar")
        
//        let actionName = "plusBtnDidClick"
        
        mainTabbar.plusBtn.addTarget(self, action: "plusBtnDidClick", forControlEvents: .TouchUpInside)
        
        addChildViewControllers()
        
    }

    private func addChildViewControllers() {
        addChildViewController(HomeTableViewController(), title: "首页", imageName: "tabbar_home")
        addChildViewController(MessageTableViewController(), title: "消息", imageName: "tabbar_message_center")
        addChildViewController(DiscoverTableViewController(), title: "发现", imageName: "tabbar_discover")
        addChildViewController(ProfileTableViewController(), title: "我", imageName: "tabbar_profile")
    }
    
  
    //添加多个视图控制器
    private func addChildViewController(vc: UIViewController,title: String,imageName:String) {
        //设置渲染颜色
        vc.tabBarItem.image = UIImage(named: imageName)
        self.tabBar.tintColor = UIColor.orangeColor()
        vc.title = title
        let nav = UINavigationController(rootViewController: vc)
        addChildViewController(nav)
    }
    

}
